<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml" 
				xmlns:h="http://java.sun.com/jsf/html"
    			xmlns:f="http://java.sun.com/jsf/core" 
    			xmlns:ui="http://java.sun.com/jsf/facelets" 
    			xmlns:a4j="http://richfaces.org/a4j"
    			xmlns:rich="http://richfaces.org/rich"
    			xmlns:c="http://java.sun.com/jsp/jstl/core"	>
    			
<!-- Ho dovuto ridefinire questo div perchè non mi veniva settata l' altezza minima della tab  -->
<h:outputStylesheet>
    .rf-tab-cnt {
		min-height: 300px;
} 
</h:outputStylesheet>

	

<rich:tabPanel id="tabsPanel"  switchType="client"  activeItem="#{tabsBean.activeTab}"   itemChangeListener="#{tabsBean.tabChange()}"  >
	  
     	<rich:tab name="Dash">
     		
     		<h:form>
     		
     				<h:outputText value="Ti è stato assegnato il ruolo Cliente con questo ruolo puoi soltanto vedere le tue fatture e i tuoi ordini" 
     				rendered="#{rich:isUserInRole('Cliente')}" styleClass="labelClass" />	
     			
     				<ui:include src="/pages/dashAdmin.xhtml"   />
     				
     		</h:form>	
     	</rich:tab>
     	
     	
     	<c:forEach var="tab" items="#{tabsBean.tabs}" >
     		<rich:tab name="#{tab.name}"  onheaderclick="switchTab('#{tab.name}');" >
     			<f:facet name="header">
     			 	<h:panelGrid columns="2">
						<h:outputText value="#{tab.name}" />
						<h:graphicImage value="#{pathImmagini.pathImmagineElimina}" 
					    				style="width:12px; height:12px;" 
					    				onclick="myFunc('#{tab.name}'); Event.stop(event);"/>
					</h:panelGrid>
				</f:facet>
     			<h:form id="form#{tab.name}" >
					<ui:include src="#{tab.pathDaIncludere}" />
				</h:form>
			</rich:tab>
     	</c:forEach> 
     	
     	<a4j:status name="StatoLoading"
					onstart="#{rich:component('processOrdine')}.show();"
                	onstop="#{rich:component('processOrdine')}.hide();"
                	/>
     	<ui:include src="/popup/popupsUtility.xhtml" />
     	
     	
</rich:tabPanel>


<a4j:jsFunction name="switchTab" action="#{tabsBean.tabChange}" >
	<a4j:param name="param2" assignTo="#{tabsBean.nextTab}"/>
</a4j:jsFunction>

     
<a4j:jsFunction name="myFunc" action="#{tabsBean.removeTab}" 
	ajaxSingle="true" render="tabsPanel" >
	<a4j:param name="param1" assignTo="#{tabsBean.tabDaEliminare}"  />
</a4j:jsFunction>
   
</ui:composition>